﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.IO;
using System.Configuration;
using System.Web.Mvc;

namespace SCP_UNA_MVC.Libs
{
    public static class ReCaptchaHelper
    {
        public static string GenerateCaptcha( this HtmlHelper helper )  
        {  
            var captchaControl = new Recaptcha.RecaptchaControl  
                    {  
                            ID = "recaptcha",  
                            Language = "pt",
                            Theme = ConfigurationManager.AppSettings["ReCaptchaTheme"],
                            PublicKey = ConfigurationManager.AppSettings["ReCaptchaPublicKey"],
                            PrivateKey = ConfigurationManager.AppSettings["ReCaptchaPrivateKey"]                            
                    };
            var htmlWriter = new HtmlTextWriter( new StringWriter() );  
            captchaControl.RenderControl(htmlWriter);  
            return htmlWriter.InnerWriter.ToString();  
        }  
    }
}